package org.coral.server.game.module.${entityName ? lower_case}.controller;

import java.util.List;
import java.util.Map;

import org.coral.server.game.module.${entityName?lower_case}.service.${entityName}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * ${entityName}控制器
 */
@Controller
public class ${entityName}Controller {
	
	private static final Logger log = LoggerFactory.getLogger(${entityName}Controller.class);
	
	@Autowired
	private ${entityName}Service ${entityName ? uncap_first}Service;
	
	
	<#if protoReqStructList ? exists>
	<#list protoReqStructList as proto>
	
	@Action("${proto.comment}")
	@ProtocolNo(PBProtocol.${proto.name}_VALUE)
	public NetworkResponse ${proto.name}(Session session, ${proto.name} req) {
		long playerId = session.getUid();

		${protoAckStructMap[proto.name].name}Resp ack = ${protoAckStructMap[proto.name].name}Resp.newInstance();
		
		<#if protoAckStructMap[proto.name].fields ? exists>
		<#list protoAckStructMap[proto.name].fields as ackStruct>
		<#if ackStruct.name == 'code'>
		<#assign  isCode = "true"/>
		</#if>
		</#list>
		</#if>
		<#if isCode == 'true'>
		int code = ${entityName ? uncap_first}Service.${proto.name ? uncap_first}(playerId, req, ack);
		ack.setCode(code);
		<#else>
		${entityName ? uncap_first}Service.${proto.name ? uncap_first}(playerId, req, ack);
		</#if>
		return ack;
	}
	
	<#assign  isCode = "false"/>
	</#list>
	</#if>
	

}
